package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.activity.client.SeckillGoodsFeignClient;
import com.atguigu.gmall.model.activity.SeckillGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

@Controller
public class SeckillGoodsController {

    @Autowired
    private SeckillGoodsFeignClient seckillGoodsFeignClient;

    //进入秒杀的频道 页面
    @GetMapping("/index")
    public String seckillIndex(Model model){
        List<SeckillGoods> all = seckillGoodsFeignClient.findAll();
        model.addAttribute("list",all);
        return "seckill/index";
    }
    //进入秒杀的详情页面
    @GetMapping("/seckill/{skuId}.html")
    public String seckillDetail(Model model , @PathVariable Long skuId){
        SeckillGoods item = seckillGoodsFeignClient.findOne(skuId);
        model.addAttribute("item" ,item);
        return "seckill/item";
    }
}
